home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1988 April
/
Ahoy_Magazine_88-04_1988_Double_L.d64
/
Coin Challenge
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
724b
|
24 lines
1 rem ==================================
2 rem commodares problem #48-1 :
3 rem coin challenge
4 rem solution by
5 rem don donati
6 rem ==================================
90 print"[147]"
100 c$(1)="pennies":v%(1)=1:c$(2)="nickels":v%(2)=5:c$(3)="dimes":v%(3)=10
110 c$(4)="quarters":v%(4)=25:c$(5)="half-dollars":v%(5)=50:tt%=0:print"[147]"
120 for i=1 to 5
125 printtab(13)"coin challenge"
130 print c$(i);:input n%:if n%<0 then 130
140 tt%=tt%+n%*v%(i):next i
150 print:print"total: $";tt%/100
160 on sgn(tt%-100)+2 goto 170, 180, 190
170 print"less than a dollar":print "add:":goto 200
180 print"equal to a dollar": end
190 print"greater than a dollar":print"remove:"
200 df%=abs(tt%-100)
210 for i=5 to 1 step -1
220 c%=df%/v%(i):if c%=0 then 240
230 df%=df%-c%*v%(i): print c%;c$(i)
240 next i : end